import { createRouter, createWebHistory } from "vue-router";

const routes = [
  {
    path: "/SanscksPane",
    component: () => import("../components/sanscks/SanscksPane.vue"),
    name: "SanscksPane",
  },
  {
    path: "/StoreUp",
    component: () => import("../components/storeup/StoreUp.vue"),
    name: "StoreUp",
  },
  {
    path: "/OrderForm",
    component: () => import("../components/orderfrom/OrderForm.vue"),
    name: "OrderForm",
  },
  {
    path: "/userMsg",
    component: () => import("../components/userMsg/userMsg.vue"),
    name: "userMsg",
  },
  {
    path: "/manage",
    component: () => import("../components/manage/manage.vue"),
    name: "manage",
  },
  {
    path: "/usermanage",
    component: () => import("../components/manage/usermanage.vue"),
    name: "usermanage",
  },
  {
    path: "/shopmanage",
    component: () => import("../components/manage/shopmanage.vue"),
    name: "shopmanage",
  },
  {
    path: "/business",
    component: () => import("../components/manage/business.vue"),
    name: "business",
  },
  {
    path: "/Nhome",
    component: () => import("../components/Nhome/titleHome.vue"),
    name: "Nhome",
  },
  {
    path: "/Csone",
    component: () => import("../components/Nhome/cs.vue"),
    name: "Csone",
  },
  {
    path: "/Card",
    component: () => import("../components/Nhome/card.vue"),
    name: "Card",
  },
  {
    path: "/cs",
    component: () => import("../components/Nhome/cs.vue"),
    name: "cs",
  },
  {
    path: "/evaluate",
    component: () => import("../components/evaluate/evaluate.vue"),
    name: "evaluate",
  },
  // zhouqi
  {
    path: "/",
    component: () => import("../components/zhouq/logon/logOn.vue"),
    name: "logOn",
  },
  {
    path: "/regiSter",
    component: () => import("../components/zhouq/register/regiSter.vue"),
    name: "regiSter",
  },
  {
    path: "/orDer",
    component: () => import("../components/zhouq/order/orDer.vue"),
    name: "orDer",
  },
  {
    path: "/takeOut",
    component: () => import("../components/zhouq/takeOout/takeOut.vue"),
    name: "takeOut",
  },
  {
    path: "/orderCompletion",
    component: () =>
      import("../components/zhouq/orderCompletion/orderCompletion.vue"),
    name: "orderCompletion",
  },
  {
    path: "/tangshi",
    component: () => import("../components/zhouq/tangShi/tangshi.vue"),
    name: "tangshi",
  },
  {
    path: "/searchdetal",
    component: () => import("../components/search/search.vue"),
    name: "searchdetal",
  },
];
const router = createRouter({
  history: createWebHistory(),
  routes,
});
export default router;
router.beforeEach((to, from, next) => {
  if (to.path === "/" || to.path === "/regiSter" || to.path === "/manage")
    return next();
  const tokenStr = window.sessionStorage.getItem("usertaken");
  if (!tokenStr) {
    alert("请登录");
    return next("/");
  }
  next();
});
